package com.orange.core.util.function;

public class CheckedExWrapper {

    public static <T, R> R function(ThrowingFunction<T, R, Exception> function, T t) {
        try {
            return function.apply(t);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static <T> void consumer(ThrowingConsumer<T, Exception> consumer, T t) {
        try {
            consumer.accept(t);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static <R> R supplier(ThrowingSupplier<R, Exception> supplier) {
        try {
            return supplier.get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void common(ThrowingCommon<Exception> common) {
        try {
            common.does();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
